﻿using System;
using System.Collections.Generic;
using Bussiness.Model;
using Bussiness.Model.Type;
using Bussiness.Service.Base;
using Bussiness.Service.Impl;

namespace Bussiness.Service.Factory {
    public class NewServiceUtil {
        private static INewService _service;
        private static INewService Service { get { return _service ?? (_service = new NewServiceImpl()); } }

        public static New GetById(long id) {
            return Service.FindById(id);
        }

        public static New FetchById(long id) {
            return Service.FetchById(id);
        }

        public static New Update(New _new) {
            _new.ModifiedDate = DateTime.Now;
            return Service.MakePersistance(_new);
        }

        public static void Delete(New _new) {
            Service.MakeTransient(_new);
        }

        public static IList<New> FillAll() {
            return Service.FindAll();
        }

        public static New Add(New _new) {
            _new.CreatedDate = DateTime.Now;
            return Update(_new);
        }

        public static IList<New> Search(string keyword, Language lang) {
            return Service.Search(keyword, lang);
        }

        public static int CountWithKeyWord(string keyword, Language lang) {
            return Service.CountByKeyWord(keyword, lang);
        }

        public static IList<New> Search(string keyword, Language lang, int start, int range, string orderProperty) {
            return Service.Search(keyword, lang, start, range, orderProperty);
        }

        public static IList<New> GetByCategory(Category category, Language lang) {
            return Service.GetByCategory(category, lang);
        }

        public static IList<New> GetByCategory(long categoryId, Language lang) {
            return Service.GetByCategory(categoryId, lang);
        }

        public static New GetFirstResult(Category category, Language lang) {
            return Service.GetFirstResult(category, lang);
        }

        public static New GetFirstResult(long categoryId, Language lang) {
            return Service.GetFirstResult(categoryId, lang);
        }

        public static IList<New> GetByCategory(Category category, Language lang, int start, int range, string orderProperty) {
            return Service.GetByCategory(category, lang, start, range, orderProperty);
        }

        public static IList<New> GetByCategory(long categoryId, Language lang, int start, int range, string orderProperty) {
            return Service.GetByCategory(categoryId, lang, start, range, orderProperty);
        }

        public static int CountByCategory(Category category, Language lang) {
            return Service.CountByCategory(category, lang);
        }

        public static int CountByCategory(long categoryId, Language lang) {
            return Service.CountByCategory(categoryId, lang);
        }
    }
}